package com.example.sample.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.example.app.BaseActivity;
import com.example.sample.R;

import net.liteheaven.xblib.common.ui.ToastUtil;

import java.io.Serializable;

/**
 * Created by liangy on 2016/12/15.
 */
public class MethodRebornActivity extends BaseActivity {

    public static class PerformOnClick implements Serializable{
        public MyRunnable runnable;
    }

    public static class MyRunnable implements Serializable{
        private String arg;
        public MyRunnable(String arg){
            this.arg = arg;
        }
        public void show(Context ctx){
            ToastUtil.show(ctx, arg);
        }
    }

    private Button btn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_method_reborn);
        btn = (Button)findViewById(R.id.btn);
        btn.setText("跳转下一个界面");
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PerformOnClick performOnClick = new PerformOnClick();
                performOnClick.runnable = new MyRunnable("来自上一个界面");
                Intent intent = new Intent(MethodRebornActivity.this, MethodReborn2Activity.class);
                intent.putExtra("tag", "我是参数");
                intent.putExtra("callback", performOnClick);
                startActivity(intent);
            }
        });
    }
}
